package com.education.service.impl;

import com.education.domain.Tbclass;
import com.education.domain.TbclassExample;
import com.education.mapper.TbclassMapper;
import com.education.service.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by zhangjiawen on 2019/11/21.
 */
@Service
public class ClassServiceImpl implements ClassService {
    @Autowired
    private TbclassMapper tbclassMapper;

    @Override
    public List<Tbclass> getAll() {

        return tbclassMapper.selectByExample(new TbclassExample());
    }

    @Override
    public List<Tbclass> getByCondition(Tbclass tbclass) {
        TbclassExample tbclassExample=new TbclassExample();
        TbclassExample.Criteria criteria = tbclassExample.createCriteria();
        if (tbclass.getLtermid()!=null){
            criteria.andLtermidEqualTo(tbclass.getLtermid());
        }
        if (tbclass.getLheadmasterid()!=null){
            criteria.andLheadmasteridEqualTo(tbclass.getLheadmasterid());
        }
        if (tbclass.getNgrade()!=null){
            criteria.andNgradeEqualTo(tbclass.getNgrade());
        }
        if (tbclass.getLid()!=null){
            criteria.andLidEqualTo(tbclass.getLid());
        }
        if (tbclass.getStrclassname()!=null){
            criteria.andStrclassnameEqualTo(tbclass.getStrclassname());
        }
        tbclassExample.setOrderByClause("nGrade");

        return tbclassMapper.selectByExample(tbclassExample);
    }






}
